#ifndef SHOW_PUB_H
#define SHOW_PUB_H

#include"common_include.h"
#include <image_transport/image_transport.h>
#include"frame.h"
#include<cv_bridge/cv_bridge.h>
#include"map.h"

namespace test_visual_odom{

class ShowPub{
public:
    EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
    typedef std::shared_ptr<ShowPub> Ptr;

    ShowPub();

    ShowPub(ros::NodeHandle& nh){
        nh_ = nh;
        image_transport::ImageTransport it(nh_);
        frame_pub_ = it.advertise("det_current_frame", 1);
        pc_landmarks_pub_ = nh_.advertise<sensor_msgs::PointCloud2>("pc_landmark",10);
    }

    void pub_frame(shared_ptr<Frame> p_frame);

    void pub_landmark();  //这里是指针，只是访问内存，后面有后端优化的话，需要考虑多线程问题

    void updateMap(shared_ptr<Map> map);

private:
    ros::NodeHandle nh_;

    image_transport::Publisher frame_pub_;

    shared_ptr<Frame> p_current_frame_ = nullptr, 
                            p_last_frame_= nullptr;

    int img_height_,img_width_;

    Map::LandmarksType all_landmarks_;
    pcl::PointCloud<PointType>::Ptr pc_landmarks_;
    ros::Publisher pc_landmarks_pub_;

   cv::Mat plotFrameImage(shared_ptr<Frame> p_frame);


};

}
#endif  
